Skip to content

Instantly share code, notes, and snippets.

@amiracam
Created January 29, 2014 17:46
Show Gist options
  • Save amiracam/8693124 to your computer and use it in GitHub Desktop.
Save amiracam/8693124 to your computer and use it in GitHub Desktop.
DateTime issue , time showing up as midnite
require 'test/unit'
require 'uuidtools'
require 'orientdb'
include OrientDB
include OrientDB::SQL
include UUIDTools
class OrientDBTest < Test::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
$db = DocumentDatabase.connect "remote:192.168.54.130/tbomc", 'writer', 'writer'
end
# Called after every test method runs. Can be used to tear
# down fixture information.
def teardown
$db.close
end
def test_connecting
assert_false ($db.is_closed?)
end
def test_creating_message
uuid = UUID.timestamp_create
attribs = { app_id: 'MC', origin: 'Baker', msg_id: uuid, data_type: 'Account',
submitted: DateTime.now }
message = create_new :McMessage, attribs
puts message
#Todo, setup assertions to compare returned obj to inserted obj
xref = UUID.timestamp_create
data_attribs = { xref: xref, value_string: 'hello~there~monkey2', msg: message}
data = create_new :McData, data_attribs
xref = UUID.timestamp_create
data_attribs = { xref: xref, value_string: 'hello~there~monkey3', msg: message }
data2 = create_new :McData, data_attribs
message.data = [data, data2]
rs = message.save
puts rs
puts data
msg_from_db = $db.find_by_rid(message.rid)
msg_from_db.data.each {|ea| puts ea.xref}
message.notified = DateTime.now
message.save
msg_from_db = $db.find_by_rid(message.rid)
puts "Notified: #{msg_from_db.notified}\nSubmitted #{msg_from_db.submitted}"
end
def create_new type, attribs
Document.create $db, type, attribs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment