talia_core 0.5.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/config/talia_core.yml.example +37 -35
- data/generators/talia_admin/templates/app/models/fake_source.rb +93 -0
- data/generators/talia_admin/templates/app/models/talia_collection.rb +13 -37
- data/generators/talia_base/talia_base_generator.rb +0 -1
- data/generators/talia_base/templates/app/controllers/custom_templates_controller.rb +2 -1
- data/generators/talia_base/templates/app/controllers/sources_controller.rb +1 -1
- data/generators/talia_base/templates/script/configure_talia +56 -73
- data/generators/talia_swicky/talia_swicky_generator.rb +18 -0
- data/generators/talia_swicky/templates/app/controllers/swicky_notebooks_controller.rb +111 -0
- data/generators/talia_swicky/templates/app/helpers/swicky_notebooks_helper.rb +29 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.builder +6 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.html.erb +10 -0
- data/generators/talia_swicky/templates/app/views/swicky_notebooks/show.html.erb +11 -0
- data/generators/talia_swicky/templates/test/fixtures/notebook.rdf +862 -0
- data/generators/talia_swicky/templates/test/functional/swicky_notebooks_controller_test.rb +44 -0
- data/lib/core_ext/boolean.rb +23 -0
- data/lib/core_ext/jdbc_rake_monkeypatch.rb +22 -0
- data/lib/core_ext/nil_class.rb +11 -0
- data/lib/core_ext/object.rb +34 -0
- data/lib/core_ext/string.rb +15 -0
- data/lib/custom_template.rb +3 -1
- data/lib/loader_helper.rb +16 -3
- data/lib/mysql.rb +7 -7
- data/lib/progressbar.rb +2 -2
- data/lib/swicky/exhibit_json/item.rb +129 -0
- data/lib/swicky/exhibit_json/item_collection.rb +129 -0
- data/lib/swicky/fragment.rb +0 -0
- data/lib/swicky/note.rb +7 -0
- data/lib/swicky/notebook.rb +78 -12
- data/lib/talia_core/active_source.rb +45 -13
- data/lib/talia_core/active_source_parts/class_methods.rb +154 -26
- data/lib/talia_core/active_source_parts/finders.rb +49 -26
- data/lib/talia_core/active_source_parts/predicate_handler.rb +71 -23
- data/lib/talia_core/active_source_parts/rdf/ntriples_reader.rb +13 -0
- data/lib/talia_core/active_source_parts/rdf/rdf_reader.rb +99 -0
- data/lib/talia_core/active_source_parts/rdf/rdfxml_reader.rb +12 -0
- data/lib/talia_core/active_source_parts/{rdf.rb → rdf_handler.rb} +52 -19
- data/lib/talia_core/active_source_parts/xml/generic_reader.rb +151 -260
- data/lib/talia_core/active_source_parts/xml/generic_reader_add_statements.rb +97 -0
- data/lib/talia_core/active_source_parts/xml/generic_reader_helpers.rb +88 -0
- data/lib/talia_core/active_source_parts/xml/generic_reader_import_statements.rb +239 -0
- data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +14 -7
- data/lib/talia_core/active_source_parts/xml/source_builder.rb +7 -3
- data/lib/talia_core/active_source_parts/xml/source_reader.rb +17 -2
- data/lib/talia_core/collection.rb +192 -1
- data/lib/talia_core/data_types/data_loader.rb +88 -18
- data/lib/talia_core/data_types/data_record.rb +24 -2
- data/lib/talia_core/data_types/delayed_copier.rb +13 -3
- data/lib/talia_core/data_types/file_record.rb +24 -13
- data/lib/talia_core/data_types/file_store.rb +111 -94
- data/lib/talia_core/data_types/iip_data.rb +104 -23
- data/lib/talia_core/data_types/iip_loader.rb +102 -56
- data/lib/talia_core/data_types/image_data.rb +3 -1
- data/lib/talia_core/data_types/media_link.rb +4 -1
- data/lib/talia_core/data_types/mime_mapping.rb +65 -38
- data/lib/talia_core/data_types/path_helpers.rb +23 -17
- data/lib/talia_core/data_types/pdf_data.rb +9 -6
- data/lib/talia_core/data_types/simple_text.rb +5 -4
- data/lib/talia_core/data_types/xml_data.rb +53 -25
- data/lib/talia_core/dummy_handler.rb +3 -2
- data/lib/talia_core/errors.rb +13 -27
- data/lib/talia_core/initializer.rb +44 -4
- data/lib/talia_core/oai/active_source_model.rb +13 -6
- data/lib/talia_core/oai/active_source_oai_adapter.rb +13 -12
- data/lib/talia_core/rdf_import.rb +1 -1
- data/lib/talia_core/rdf_resource.rb +2 -1
- data/lib/talia_core/semantic_collection_wrapper.rb +143 -151
- data/lib/talia_core/semantic_property.rb +4 -0
- data/lib/talia_core/semantic_relation.rb +84 -33
- data/lib/talia_core/source.rb +45 -25
- data/lib/talia_core/source_fragment.rb +7 -0
- data/lib/talia_core/source_transfer_object.rb +3 -1
- data/lib/talia_core/source_types/agent.rb +16 -0
- data/lib/talia_core/source_types/dc_resource.rb +3 -3
- data/lib/talia_core/source_types/marcont_resource.rb +15 -0
- data/lib/talia_core/source_types/skos_concept.rb +17 -0
- data/lib/talia_dependencies.rb +1 -1
- data/lib/talia_util.rb +1 -1
- data/lib/talia_util/bar_progressor.rb +1 -1
- data/lib/talia_util/image_conversions.rb +8 -2
- data/lib/talia_util/import_job_helper.rb +40 -3
- data/lib/talia_util/io_helper.rb +15 -4
- data/lib/talia_util/progressable.rb +50 -1
- data/lib/talia_util/rake_tasks.rb +3 -21
- data/lib/talia_util/test_helpers.rb +6 -1
- data/lib/talia_util/util.rb +108 -27
- data/lib/talia_util/xml/base_builder.rb +28 -1
- data/lib/talia_util/xml/rdf_builder.rb +81 -5
- data/lib/tasks/talia_core_tasks.rake +2 -0
- data/test/core_ext/boolean_test.rb +26 -0
- data/test/core_ext/nil_class_test.rb +14 -0
- data/test/core_ext/object_test.rb +26 -0
- data/test/core_ext/string_test.rb +11 -0
- data/test/swicky/json_encoder_test.rb +51 -42
- data/test/swicky/notebook_test.rb +13 -6
- data/test/talia_core/active_source_finder_interface_test.rb +30 -0
- data/test/talia_core/active_source_test.rb +445 -34
- data/test/talia_core/collection_test.rb +332 -0
- data/test/talia_core/data_types/file_record_test.rb +2 -23
- data/test/talia_core/ntriples_reader_test.rb +49 -0
- data/test/talia_core/rdfxml_reader_test.rb +51 -0
- data/test/talia_core/source_test.rb +12 -0
- data/test/talia_util/import_job_helper_test.rb +19 -12
- metadata +190 -90
- data/config/database.yml +0 -19
- data/config/rdfstore.yml +0 -13
- data/config/talia_core.yml +0 -24
- data/generators/talia_base/templates/migrations/bj_migration.rb +0 -10
- data/lib/JXslt/jxslt.rb +0 -60
- data/lib/swicky/json_encoder.rb +0 -179
- data/lib/talia_core/agent.rb +0 -14
- data/lib/talia_core/background_jobs/job.rb +0 -82
- data/lib/talia_core/background_jobs/progress_job.rb +0 -68
- data/lib/talia_core/data_types/temp_file_handling.rb +0 -85
- data/lib/talia_core/ordered_source.rb +0 -228
- data/lib/talia_core/semantic_collection_item.rb +0 -94
- data/lib/talia_core/source_types/collection.rb +0 -15
- data/lib/talia_util/progressbar.rb +0 -236
- data/tasks/talia_core_tasks.rake +0 -2
- data/test/talia_core/ordered_source_test.rb +0 -394
- data/test/talia_core/semantic_collection_item_test.rb +0 -125
@@ -0,0 +1,30 @@
|
|
1
|
+
#http://m.onkey.org/2010/1/22/active-record-query-interface
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
4
|
+
|
5
|
+
module TaliaCore
|
6
|
+
|
7
|
+
# Test the ActiveSource
|
8
|
+
class ActiveSourceFinderInterfaceTest < ActiveSupport::TestCase
|
9
|
+
fixtures :active_sources, :semantic_properties, :semantic_relations, :data_records
|
10
|
+
|
11
|
+
|
12
|
+
def setup
|
13
|
+
setup_once(:test_file) { File.join(ActiveSupport::TestCase.fixture_path, 'generic_test.xml') }
|
14
|
+
setup_once(:default_sources) do
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_where
|
20
|
+
#result = ActiveSource.find(:all, :find_through => ['http://testvalue.org/pred_find_through', active_sources(:find_through_target).uri])
|
21
|
+
result = ActiveSource.where('http://testvalue.org/pred_find_through' => active_sources(:find_through_target).uri)
|
22
|
+
assert_equal(1, result.size)
|
23
|
+
assert_equal(active_sources(:find_through_test), result[0])
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -1,10 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
3
|
|
3
4
|
module TaliaCore
|
4
5
|
|
5
|
-
class
|
6
|
-
|
6
|
+
class DefinedAccessorTest < ActiveSource
|
7
|
+
autofill_uri
|
8
|
+
singular_property :siglum, N::RDFS.siglum, :dependent => :destroy
|
9
|
+
multi_property :authors, N::RDFS.author
|
10
|
+
singular_property :forcy_single, N::RDFS.forcy_single, :type => TaliaCore::ActiveSource
|
11
|
+
multi_property :forcy, N::RDFS.forcy, :type => TaliaCore::Source, :dependent => :destroy
|
12
|
+
manual_property :blinko
|
13
|
+
|
14
|
+
multi_property :optionated, N::RDFS.optionated, :type => TaliaCore::ActiveSource
|
15
|
+
|
7
16
|
has_rdf_type N::TALIA.foo
|
17
|
+
|
18
|
+
attr_accessor :blinko
|
19
|
+
end
|
20
|
+
|
21
|
+
class DefinedAccessorSubTest < DefinedAccessorTest
|
22
|
+
singular_property :title, N::RDFS.title
|
23
|
+
|
24
|
+
property_options N::RDFS.optionated, :dependent => :destroy
|
25
|
+
multi_property :optionated2, N::RDFS.optionated2, :type => TaliaCore::ActiveSource
|
26
|
+
end
|
27
|
+
|
28
|
+
class DefinedAccessorSubNaked < DefinedAccessorTest
|
8
29
|
end
|
9
30
|
|
10
31
|
# Test the ActiveSource
|
@@ -20,6 +41,7 @@ module TaliaCore
|
|
20
41
|
def test_has_type
|
21
42
|
src = ActiveSource.new('http://xsource/has_type_test')
|
22
43
|
src.types << N::HYPER.testtype
|
44
|
+
|
23
45
|
assert(src.has_type?(N::HYPER.testtype))
|
24
46
|
end
|
25
47
|
|
@@ -305,8 +327,8 @@ module TaliaCore
|
|
305
327
|
end
|
306
328
|
|
307
329
|
def test_sti_simple # Single table inheritance
|
308
|
-
assert_kind_of(TaliaCore::
|
309
|
-
assert_kind_of(TaliaCore::
|
330
|
+
assert_kind_of(TaliaCore::Collection, ActiveSource.find(:first, :conditions => { :uri => active_sources(:sti_source).uri.to_s } ))
|
331
|
+
assert_kind_of(TaliaCore::Collection, active_sources(:sti_source))
|
310
332
|
end
|
311
333
|
|
312
334
|
def test_sti_relation_create
|
@@ -316,14 +338,14 @@ module TaliaCore
|
|
316
338
|
src.save!
|
317
339
|
assert_equal(1, src['http://reltest_test'].size)
|
318
340
|
assert_equal(1, src['http://reltest_test_b'].size)
|
319
|
-
assert_equal(TaliaCore::
|
341
|
+
assert_equal(TaliaCore::Collection, src['http://reltest_test'][0].class)
|
320
342
|
assert_equal(TaliaCore::ActiveSource, src['http://reltest_test_b'][0].class)
|
321
343
|
end
|
322
344
|
|
323
345
|
def test_sti_relation_inverse
|
324
346
|
assert_equal(1, active_sources(:sti_source_b).subjects.size)
|
325
|
-
assert_equal(TaliaCore::
|
326
|
-
assert_equal(TaliaCore::
|
347
|
+
assert_equal(TaliaCore::Collection, active_sources(:sti_source_b).subjects[0].class)
|
348
|
+
assert_equal(TaliaCore::Collection, active_sources(:sti_source_b).inverse['http://testvalue.org/sti_test'][0].class)
|
327
349
|
assert_equal(active_sources(:sti_source).uri, active_sources(:sti_source_b).inverse['http://testvalue.org/sti_test'][0].uri)
|
328
350
|
end
|
329
351
|
|
@@ -354,6 +376,11 @@ module TaliaCore
|
|
354
376
|
assert_equal(N::LOCAL.testlocalthing, src.uri)
|
355
377
|
end
|
356
378
|
|
379
|
+
def test_create_local_strange
|
380
|
+
src = ActiveSource.new(:uri => '504-10,E2')
|
381
|
+
assert_equal(N::LOCAL + '504-10,E2', src.uri)
|
382
|
+
end
|
383
|
+
|
357
384
|
def test_assign_and_save
|
358
385
|
src = ActiveSource.new('http://testassignandsave/')
|
359
386
|
src[N::LOCAL.something] << ActiveSource.new('http://types_test/assign_and_save_a')
|
@@ -385,6 +412,27 @@ module TaliaCore
|
|
385
412
|
assert_equal(active_sources(:find_through_test), result[0])
|
386
413
|
end
|
387
414
|
|
415
|
+
def test_find_through_evil # Checks what happens if #to_s returns a random string instead of the uri
|
416
|
+
foo = Object.new
|
417
|
+
class << foo
|
418
|
+
def uri
|
419
|
+
@uri
|
420
|
+
end
|
421
|
+
|
422
|
+
def to_s
|
423
|
+
'abcd'
|
424
|
+
end
|
425
|
+
end
|
426
|
+
foo.instance_variable_set(:@uri, active_sources(:find_through_target).uri)
|
427
|
+
|
428
|
+
assert_equal(active_sources(:find_through_target).uri, foo.uri)
|
429
|
+
assert_equal('abcd', foo.to_s)
|
430
|
+
|
431
|
+
result = ActiveSource.find(:all, :find_through => ['http://testvalue.org/pred_find_through', foo])
|
432
|
+
assert_equal(1, result.size)
|
433
|
+
assert_equal(active_sources(:find_through_test), result[0])
|
434
|
+
end
|
435
|
+
|
388
436
|
def test_count_through
|
389
437
|
result = ActiveSource.count(:find_through => ['http://testvalue.org/pred_find_through', active_sources(:find_through_target).uri])
|
390
438
|
assert_equal(1, result)
|
@@ -413,8 +461,18 @@ module TaliaCore
|
|
413
461
|
assert_equal(active_sources(:find_through_test), result[0])
|
414
462
|
end
|
415
463
|
|
464
|
+
def test_singular_accessor_on_brackets
|
465
|
+
src = DefinedAccessorTest.new('http://testvalue.org/singular_acc_test')
|
466
|
+
assert_equal(nil, src[N::RDFS.siglum])
|
467
|
+
src[N::RDFS.siglum] = 'foo'
|
468
|
+
src.save!
|
469
|
+
assert_equal('foo', src[N::RDFS.siglum])
|
470
|
+
src.siglum = 'bar'
|
471
|
+
assert_equal('bar', src[N::RDFS.siglum])
|
472
|
+
end
|
473
|
+
|
416
474
|
def test_singular_accessor
|
417
|
-
src =
|
475
|
+
src = DefinedAccessorTest.new('http://testvalue.org/singular_acc_test')
|
418
476
|
assert_equal(nil, src.siglum)
|
419
477
|
src.siglum = 'foo'
|
420
478
|
src.save!
|
@@ -423,14 +481,101 @@ module TaliaCore
|
|
423
481
|
assert_equal('bar', src.siglum)
|
424
482
|
end
|
425
483
|
|
426
|
-
def
|
427
|
-
src =
|
484
|
+
def test_singular_accessor_forcing
|
485
|
+
src = DefinedAccessorTest.new('http://testvalue.org/singular_acc_forcing_test')
|
486
|
+
assert_equal(nil, src.forcy_single)
|
487
|
+
src.forcy_single = active_sources(:testy).uri.to_s
|
488
|
+
src.save!
|
489
|
+
assert_kind_of(TaliaCore::ActiveSource, src.forcy_single)
|
490
|
+
assert_equal(active_sources(:testy).uri, src.forcy_single.uri)
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_singular_accessor_destroy_dependent
|
494
|
+
src = DefinedAccessorTest.new('http://testvalue.org/test_update_attribute_multi_forced')
|
495
|
+
assert(src.forcy.blank?)
|
496
|
+
src.update_attributes(:siglum => active_sources(:deltest))
|
497
|
+
src.save!
|
498
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
499
|
+
src.destroy
|
500
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
501
|
+
end
|
502
|
+
|
503
|
+
def test_multi_accessor_forcing
|
504
|
+
src = DefinedAccessorTest.new('http://testvalue.org/multi_acc_forcing_test')
|
505
|
+
assert(src.forcy.blank?)
|
506
|
+
src.forcy = [ active_sources(:testy).uri.to_s, active_sources(:testy_two).uri.to_s ]
|
507
|
+
src.save!
|
508
|
+
assert_property(src.forcy, active_sources(:testy), active_sources(:testy_two))
|
509
|
+
end
|
510
|
+
|
511
|
+
def test_multi_accessor
|
512
|
+
src = DefinedAccessorTest.new('http://testvalue.org/multi_acc_test')
|
513
|
+
assert(src.authors.blank?)
|
514
|
+
src.authors = [ "foo", "bar", "dingdong" ]
|
515
|
+
src.save!
|
516
|
+
assert_equal([ "foo", "bar", "dingdong" ].sort, src.authors.sort)
|
517
|
+
src.authors = 'bar'
|
518
|
+
assert_equal(['bar'], src.authors.values)
|
519
|
+
end
|
520
|
+
|
521
|
+
def test_multi_accessor_destroy_dependent
|
522
|
+
src = DefinedAccessorTest.new('http://testvalue.org/test_update_attribute_multi_forced')
|
523
|
+
assert(src.forcy.blank?)
|
524
|
+
src.update_attributes(:forcy => [ active_sources(:deltest).uri.to_s ])
|
525
|
+
src.save!
|
526
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
527
|
+
src.destroy
|
528
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_singular_accessor_with_blank
|
532
|
+
src = DefinedAccessorTest.new('http://testvalue.org/singular_acc_test')
|
533
|
+
assert_equal(nil, src.siglum)
|
428
534
|
src.siglum = 'foo'
|
429
535
|
src.save!
|
430
|
-
|
536
|
+
assert_equal('foo', src.siglum)
|
537
|
+
src.siglum = ''
|
538
|
+
assert_equal(nil, src.siglum)
|
539
|
+
end
|
540
|
+
|
541
|
+
def test_defined_accessor_finder
|
542
|
+
src = DefinedAccessorTest.new('http://testvalue.org/singular_find_test')
|
543
|
+
src.siglum = 'foo'
|
544
|
+
src.save!
|
545
|
+
src2 = DefinedAccessorTest.new('http://testvalue.org/singular_find_test2')
|
431
546
|
src2.siglum = 'bar'
|
432
547
|
src2.save!
|
433
|
-
assert_equal(
|
548
|
+
assert_equal(DefinedAccessorTest.find_by_siglum('foo'), [ src ])
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_wrapper_destroy_dependent_on_remove
|
552
|
+
src = DefinedAccessorTest.new('http://testvalue.org/test_wrapper_destroy_dependent_on_remove')
|
553
|
+
assert(src[N::RDFS.forcy].blank?)
|
554
|
+
src[N::RDFS.forcy] = active_sources(:deltest)
|
555
|
+
src.save!
|
556
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
557
|
+
src[N::RDFS.forcy].remove
|
558
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_wrapper_destroy_rdf_dependent_on_remove
|
562
|
+
src = DefinedAccessorTest.new('test_wrapper_destroy_rdf_dependent_on_remove')
|
563
|
+
assert(src[N::RDFS.forcy].blank?)
|
564
|
+
src[N::RDFS.forcy] = active_sources(:deltest)
|
565
|
+
src.save!
|
566
|
+
src[N::RDFS.forcy].remove
|
567
|
+
assert_equal([], ActiveRDF::Query.new(N::URI).select(:a, :b).where(active_sources(:deltest), :a, :b).execute)
|
568
|
+
assert_equal([], ActiveRDF::Query.new(N::URI).select(:a, :b).where(:a, :b, active_sources(:deltest)).execute)
|
569
|
+
end
|
570
|
+
|
571
|
+
def test_wrapper_not_destroy_nondependent_on_remove
|
572
|
+
src = DefinedAccessorTest.new('test_wrapper_not_destroy_nondependent_on_remove')
|
573
|
+
assert(src[N::RDFS.fuzzy].blank?)
|
574
|
+
src[N::RDFS.fuzzy] = active_sources(:deltest)
|
575
|
+
src.save!
|
576
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
577
|
+
src[N::RDFS.fuzzy].remove
|
578
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
434
579
|
end
|
435
580
|
|
436
581
|
def test_autosave_rdf
|
@@ -489,6 +634,49 @@ module TaliaCore
|
|
489
634
|
src.save!
|
490
635
|
assert_equal(2, src['http://activesourcetest/write_predicate'].size)
|
491
636
|
end
|
637
|
+
|
638
|
+
def test_replace_predicate
|
639
|
+
src = ActiveSource.new('http://activesourcetest/test_replace_predicate')
|
640
|
+
src[N::RDF.foo] = [ active_sources(:testy), active_sources(:deltest) ]
|
641
|
+
src.save!
|
642
|
+
assert_property(src[N::RDF.foo], active_sources(:testy), active_sources(:deltest))
|
643
|
+
src[N::RDF.foo].replace(active_sources(:testy_two))
|
644
|
+
assert_property(src[N::RDF.foo], active_sources(:testy_two))
|
645
|
+
end
|
646
|
+
|
647
|
+
def test_replace_predicate_no_dependent_on_base_class
|
648
|
+
src = ActiveSource.new('http://activesourcetest/test_replace_predicate')
|
649
|
+
src[N::RDFS.forcy] = [ active_sources(:testy), active_sources(:deltest) ]
|
650
|
+
src.save!
|
651
|
+
assert_property(src[N::RDFS.forcy], active_sources(:testy), active_sources(:deltest))
|
652
|
+
src[N::RDFS.forcy].replace(active_sources(:testy_two), active_sources(:testy))
|
653
|
+
assert_property(src[N::RDFS.forcy], active_sources(:testy_two), active_sources(:testy))
|
654
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:testy).id), "Source shouldn't be destroyed")
|
655
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id), "Source shouldn't be destroyed")
|
656
|
+
end
|
657
|
+
|
658
|
+
def test_replace_predicate_with_dependent_destroy
|
659
|
+
src = DefinedAccessorTest.new('http://activesourcetest/test_replace_predicate_with_dependent_destroy')
|
660
|
+
src[N::RDFS.forcy] = [ active_sources(:testy), active_sources(:deltest) ]
|
661
|
+
src.save!
|
662
|
+
assert_property(src[N::RDFS.forcy], active_sources(:testy), active_sources(:deltest))
|
663
|
+
src[N::RDFS.forcy].replace(active_sources(:testy_two).uri.to_s, active_sources(:testy))
|
664
|
+
assert_property(src[N::RDFS.forcy], active_sources(:testy_two), active_sources(:testy))
|
665
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:testy).id), "Remaining source should still exist")
|
666
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id), "Removed source should be deleted")
|
667
|
+
end
|
668
|
+
|
669
|
+
def test_replace_with_string_for_source
|
670
|
+
src = DefinedAccessorTest.new('http://activesourcetest/test_replace_with_string_for_source')
|
671
|
+
src[N::RDFS.forcy] = [ active_sources(:deltest) ]
|
672
|
+
src.save!
|
673
|
+
assert_property(src[N::RDFS.forcy], active_sources(:deltest))
|
674
|
+
src[N::RDFS.forcy].replace(active_sources(:deltest).uri.to_s)
|
675
|
+
src.save!
|
676
|
+
src.reload
|
677
|
+
assert_property(src[N::RDFS.forcy], active_sources(:deltest))
|
678
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id), "Source shouldn't have been destroyed")
|
679
|
+
end
|
492
680
|
|
493
681
|
def test_double_add_new_source
|
494
682
|
src = ActiveSource.new('http://activesourcetest/doubletest')
|
@@ -504,7 +692,7 @@ module TaliaCore
|
|
504
692
|
src = ActiveSource.new('http://activesourcetest/doubleadd/test')
|
505
693
|
src[N::HYPER.bar] << 'foo'
|
506
694
|
src.save!
|
507
|
-
src2 =
|
695
|
+
src2 = ActiveSource.find(src.uri)
|
508
696
|
src2[N::HYPER.bar] << 'bar'
|
509
697
|
src2.save!
|
510
698
|
assert_property(ActiveSource.find(src.uri)[N::HYPER.bar], 'foo', 'bar')
|
@@ -559,6 +747,51 @@ module TaliaCore
|
|
559
747
|
assert_property(src[N::LOCAL.relatit], N::LOCAL.attr_update_test_dummy, N::LOCAL.another_attribute_save_dummy)
|
560
748
|
end
|
561
749
|
|
750
|
+
def test_update_attribute_singular
|
751
|
+
src = DefinedAccessorTest.new('http://as_test/test_update_attribute_singular')
|
752
|
+
src.update_attributes(:siglum => "foo my ass")
|
753
|
+
assert_equal('foo my ass', src.siglum)
|
754
|
+
end
|
755
|
+
|
756
|
+
def test_update_attribute_singular_forced
|
757
|
+
src = DefinedAccessorTest.new('http://as_test/test_update_attribute_singular_forced')
|
758
|
+
src.update_attributes(:forcy_single => active_sources(:testy).uri.to_s)
|
759
|
+
assert_kind_of(TaliaCore::ActiveSource, src.forcy_single)
|
760
|
+
assert_equal(active_sources(:testy).uri, src.forcy_single.uri)
|
761
|
+
end
|
762
|
+
|
763
|
+
def test_update_attribute_singular_destroy
|
764
|
+
src = DefinedAccessorTest.new(:uri => 'http://as_test/test_update_attribute_singular_destroy',
|
765
|
+
:siglum => active_sources(:deltest))
|
766
|
+
src.save!
|
767
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
768
|
+
src.update_attributes(:siglum => "")
|
769
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
770
|
+
end
|
771
|
+
|
772
|
+
def test_update_attribute_multi
|
773
|
+
src = DefinedAccessorTest.new('http://as_test/test_update_attribute_multi')
|
774
|
+
src.update_attributes(:authors => [ "fooby", "barni", "doc garfield" ])
|
775
|
+
assert_equal([ "fooby", "barni", "doc garfield" ].sort, src.authors.sort)
|
776
|
+
end
|
777
|
+
|
778
|
+
def test_update_attribute_multi_forced
|
779
|
+
src = DefinedAccessorTest.new('http://testvalue.org/test_update_attribute_multi_forced')
|
780
|
+
assert(src.forcy.blank?)
|
781
|
+
src.update_attributes(:forcy => [ active_sources(:testy).uri.to_s, active_sources(:testy_two).uri.to_s ])
|
782
|
+
src.save!
|
783
|
+
assert_property(src.forcy, active_sources(:testy), active_sources(:testy_two))
|
784
|
+
end
|
785
|
+
|
786
|
+
def test_update_attribute_multi_destroy
|
787
|
+
src = DefinedAccessorTest.new(:uri => 'http://as_test/test_update_attribute_multi_destroy',
|
788
|
+
:forcy => active_sources(:deltest))
|
789
|
+
src.save!
|
790
|
+
assert(TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
791
|
+
src.update_attributes(:forcy => [])
|
792
|
+
assert(!TaliaCore::ActiveSource.exists?(active_sources(:deltest).id))
|
793
|
+
end
|
794
|
+
|
562
795
|
def test_update_adding
|
563
796
|
src = ActiveSource.new('http://as_test/test_update_adding')
|
564
797
|
src[N::RDF.something] << 'value1'
|
@@ -575,14 +808,14 @@ module TaliaCore
|
|
575
808
|
|
576
809
|
def test_rewrite_type
|
577
810
|
src = ActiveSource.new('http://as_test/test_update_rewrite_type')
|
578
|
-
src.rewrite_attributes!({}) { |src| src.type = 'TaliaCore::
|
579
|
-
assert_kind_of(
|
811
|
+
src.rewrite_attributes!({}) { |src| src.type = 'TaliaCore::DefinedAccessorTest' }
|
812
|
+
assert_kind_of(DefinedAccessorTest, ActiveSource.find(src.uri))
|
580
813
|
end
|
581
814
|
|
582
815
|
def test_rewrite_type
|
583
816
|
src = ActiveSource.new('http://as_test/test_update_type')
|
584
|
-
src.update_attributes!({}) { |src| src.type = 'TaliaCore::
|
585
|
-
assert_kind_of(
|
817
|
+
src.update_attributes!({}) { |src| src.type = 'TaliaCore::DefinedAccessorTest' }
|
818
|
+
assert_kind_of(DefinedAccessorTest, ActiveSource.find(src.uri))
|
586
819
|
end
|
587
820
|
|
588
821
|
def test_update_static
|
@@ -604,10 +837,24 @@ module TaliaCore
|
|
604
837
|
end
|
605
838
|
|
606
839
|
def test_create_with_attributes
|
607
|
-
src = ActiveSource.new(:uri => 'http://as_test/create_with_attributes', ':localthi' => 'value', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:
|
840
|
+
src = ActiveSource.new(:uri => 'http://as_test/create_with_attributes', ':localthi' => 'value', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:as_create_attr_dummy_2>"])
|
608
841
|
assert_equal('http://as_test/create_with_attributes', src.uri)
|
609
842
|
assert_equal('value', src[N::LOCAL.localthi].first)
|
610
|
-
assert_property(src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.
|
843
|
+
assert_property(src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.as_create_attr_dummy_2)
|
844
|
+
end
|
845
|
+
|
846
|
+
def test_create_with_duplicate_attributes
|
847
|
+
src = ActiveSource.new(:uri => 'http://as_test/create_with_attributes', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:as_create_attr_dummy_1>"])
|
848
|
+
assert_property(src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1)
|
849
|
+
end
|
850
|
+
|
851
|
+
def test_create_with_attributes_and_forcing
|
852
|
+
src = DefinedAccessorTest.new(:uri => 'test_create_with_attributes_and_forcing', 'forcy_single' => active_sources(:deltest).uri.to_s)
|
853
|
+
assert_kind_of(ActiveSource, src.forcy_single)
|
854
|
+
assert_equal(active_sources(:deltest).uri, src.forcy_single.uri)
|
855
|
+
src.save!
|
856
|
+
src.reload
|
857
|
+
assert_kind_of(ActiveSource, src.forcy_single)
|
611
858
|
end
|
612
859
|
|
613
860
|
def test_create_with_attributes_plain_uri
|
@@ -616,15 +863,15 @@ module TaliaCore
|
|
616
863
|
end
|
617
864
|
|
618
865
|
def test_create_source
|
619
|
-
src = ActiveSource.create_source(:uri => 'http://as_test/create_with_type', ':localthi' => 'value', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:
|
620
|
-
assert_kind_of(
|
866
|
+
src = ActiveSource.create_source(:uri => 'http://as_test/create_with_type', ':localthi' => 'value', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:as_create_attr_dummy_2>"], 'type' => 'TaliaCore::DefinedAccessorTest')
|
867
|
+
assert_kind_of(DefinedAccessorTest, src)
|
621
868
|
assert_equal('value', src[N::LOCAL.localthi].first)
|
622
|
-
assert_property(src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.
|
869
|
+
assert_property(src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.as_create_attr_dummy_2)
|
623
870
|
assert_property(src.types, N::TALIA.foo, src.rdf_selftype)
|
624
871
|
end
|
625
872
|
|
626
873
|
def test_create_for_existing
|
627
|
-
src = ActiveSource.create_source(:uri => 'http://as_test/create_forth_and_existing', ':localthi' => 'valueFOOOO', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:
|
874
|
+
src = ActiveSource.create_source(:uri => 'http://as_test/create_forth_and_existing', ':localthi' => 'valueFOOOO', 'rdf:relatit' => ["<:as_create_attr_dummy_1>", "<:as_create_attr_dummy_2>"], 'type' => 'TaliaCore::DefinedAccessorTest')
|
628
875
|
src.save!
|
629
876
|
assert_equal('valueFOOOO', src[N::LOCAL.localthi].first)
|
630
877
|
xml = src.to_xml
|
@@ -634,21 +881,21 @@ module TaliaCore
|
|
634
881
|
# Now test as above
|
635
882
|
assert_equal(src.uri.to_s, new_src.uri.to_s)
|
636
883
|
assert_equal('valorz', new_src[N::LOCAL.localthi].first)
|
637
|
-
assert_property(new_src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.
|
884
|
+
assert_property(new_src[N::RDF.relatit], N::LOCAL.as_create_attr_dummy_1, N::LOCAL.as_create_attr_dummy_2)
|
638
885
|
assert_property(new_src.types, N::TALIA.foo, new_src.rdf_selftype)
|
639
886
|
end
|
640
887
|
|
641
888
|
def test_create_multi
|
642
889
|
src_attribs = [
|
643
|
-
{ :uri => N::LOCAL.test_create_multi_stuff, 'rdf:relatit' => [ "<#{N::LOCAL.test_create_multi_stuff_two}>" ], 'type' => 'TaliaCore::
|
644
|
-
{ :uri => N::LOCAL.test_create_multi_stuff_two, ':localthi' => 'valueFOOOO', 'rdf:relatit' => ["<#{N::LOCAL.test_create_multi_stuff}>"], 'type' => 'TaliaCore::
|
890
|
+
{ :uri => N::LOCAL.test_create_multi_stuff, 'rdf:relatit' => [ "<#{N::LOCAL.test_create_multi_stuff_two}>" ], 'type' => 'TaliaCore::DefinedAccessorTest' },
|
891
|
+
{ :uri => N::LOCAL.test_create_multi_stuff_two, ':localthi' => 'valueFOOOO', 'rdf:relatit' => ["<#{N::LOCAL.test_create_multi_stuff}>"], 'type' => 'TaliaCore::DefinedAccessorTest' }
|
645
892
|
]
|
646
893
|
ActiveSource.create_multi_from(src_attribs, :duplicates => :update)
|
647
894
|
src = TaliaCore::ActiveSource.find(N::LOCAL.test_create_multi_stuff)
|
648
895
|
src_two = TaliaCore::ActiveSource.find(N::LOCAL.test_create_multi_stuff_two)
|
649
896
|
assert(src && src_two)
|
650
|
-
assert_kind_of(
|
651
|
-
assert_kind_of(
|
897
|
+
assert_kind_of(DefinedAccessorTest, src)
|
898
|
+
assert_kind_of(DefinedAccessorTest, src_two)
|
652
899
|
assert_property(src_two[N::RDF.relatit], N::LOCAL.test_create_multi_stuff)
|
653
900
|
assert_property(src[N::RDF.relatit], N::LOCAL.test_create_multi_stuff_two)
|
654
901
|
assert_property(src_two[N::LOCAL.localthi], 'valueFOOOO')
|
@@ -662,11 +909,11 @@ module TaliaCore
|
|
662
909
|
# Quickly change the URI for the new thing
|
663
910
|
xml.gsub!(src.uri.to_s, 'http://as_test/create_forth_and_forth')
|
664
911
|
# this is for the type attribute in the xml
|
665
|
-
xml.gsub!('SourceTypes::DummySource', '
|
912
|
+
xml.gsub!('SourceTypes::DummySource', 'DefinedAccessorTest')
|
666
913
|
# The next is for the 'type' semantic triple already existing
|
667
|
-
xml.gsub!('DummySource', '
|
914
|
+
xml.gsub!('DummySource', 'DefinedAccessorTest')
|
668
915
|
new_src = ActiveSource.create_from_xml(xml, :duplicates => :update)
|
669
|
-
assert_kind_of(TaliaCore::
|
916
|
+
assert_kind_of(TaliaCore::DefinedAccessorTest, new_src)
|
670
917
|
# Now test as above
|
671
918
|
assert_equal('http://as_test/create_forth_and_forth', new_src.uri.to_s)
|
672
919
|
assert_equal('value', new_src[N::LOCAL.localthi].first)
|
@@ -762,11 +1009,178 @@ module TaliaCore
|
|
762
1009
|
assert_equal(3, src.data_records.size)
|
763
1010
|
end
|
764
1011
|
|
1012
|
+
def test_destroy_source
|
1013
|
+
# Set up some sources that are interlinked
|
1014
|
+
sources = (0..2).collect do |idx|
|
1015
|
+
src = ActiveSource.new("http://as_test/destroy_source_#{idx}")
|
1016
|
+
src.save!
|
1017
|
+
src
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
sources[0][N::TALIA.test_pred] << sources[1]
|
1021
|
+
sources[0][N::TALIA.test_pred] << sources[2]
|
1022
|
+
sources[1][N::TALIA.testy_pred] << sources[0]
|
1023
|
+
sources[1][N::TALIA.testy_pred] << sources[2]
|
1024
|
+
|
1025
|
+
sources.each { |s| s.save! }
|
1026
|
+
|
1027
|
+
# Check if everything is set up correctly
|
1028
|
+
assert_property(sources[0][N::TALIA.test_pred], sources[1], sources[2])
|
1029
|
+
assert_property(sources[1][N::TALIA.testy_pred], sources[0], sources[2])
|
1030
|
+
|
1031
|
+
# Destroy one source
|
1032
|
+
destroyed_id = sources[1].id
|
1033
|
+
sources[1].destroy
|
1034
|
+
|
1035
|
+
# Check if it took all the links with it
|
1036
|
+
test_source = TaliaCore::ActiveSource.find(sources[0].id)
|
1037
|
+
assert_property(test_source[N::TALIA.test_pred], sources[2]) # This one should have the "destroyed" connection removed
|
1038
|
+
# All relations related to that source should be gone
|
1039
|
+
assert_equal(0, TaliaCore::SemanticRelation.all(:conditions => { :subject_id => destroyed_id }).size)
|
1040
|
+
assert_equal(0, TaliaCore::SemanticRelation.all(:conditions => { :object_id => destroyed_id }).size)
|
1041
|
+
# The source should be gone
|
1042
|
+
assert(!TaliaCore::ActiveSource.exists?(sources[1].uri))
|
1043
|
+
# The RDF should be gone
|
1044
|
+
forward_result = ActiveRDF::Query.new(N::URI).select(:thing).where(sources[0], N::TALIA.test_pred, :thing).execute
|
1045
|
+
assert_equal(1, forward_result.size, "Found more than one : #{forward_result.inspect}")
|
1046
|
+
backward_result = ActiveRDF::Query.new(N::URI).select(:thing).where(sources[1], :all, :thing).execute
|
1047
|
+
assert_equal(0, backward_result.size)
|
1048
|
+
end
|
1049
|
+
|
765
1050
|
def test_to_uri
|
766
1051
|
src = ActiveSource.new('http://xsource/has_type_test')
|
767
1052
|
assert_equal(N::URI.new('http://xsource/has_type_test'), src.to_uri)
|
768
1053
|
end
|
769
1054
|
|
1055
|
+
def test_property_options_on_superclass
|
1056
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorTest.property_options_for(N::RDFS.optionated)[:type])
|
1057
|
+
assert_nil(DefinedAccessorTest.property_options_for(N::RDFS.optionated2)[:type])
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
def test_property_options_on_subclass
|
1061
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorSubTest.property_options_for(N::RDFS.optionated)[:type])
|
1062
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorSubTest.property_options_for(N::RDFS.optionated2)[:type])
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
def test_inherited_property_values_on_superclass
|
1066
|
+
assert_equal({ :type => TaliaCore::ActiveSource, :singular_property => false }, DefinedAccessorTest.property_options_for(N::RDFS.optionated))
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
def test_inherited_property_values_on_subclass
|
1070
|
+
assert_equal({ :type => TaliaCore::ActiveSource, :dependent => :destroy, :singular_property => false}, DefinedAccessorSubTest.property_options_for(N::RDFS.optionated))
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
def test_property_options_on_defined_super
|
1074
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorTest.property_options_for(:optionated)[:type])
|
1075
|
+
assert_nil(DefinedAccessorTest.property_options_for(:optionated2)[:type])
|
1076
|
+
end
|
1077
|
+
|
1078
|
+
def test_property_options_on_defined_sub
|
1079
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorSubTest.property_options_for(:optionated)[:type])
|
1080
|
+
assert_equal(TaliaCore::ActiveSource, DefinedAccessorSubTest.property_options_for(:optionated2)[:type])
|
1081
|
+
end
|
1082
|
+
|
1083
|
+
def test_has_defined_property
|
1084
|
+
assert(DefinedAccessorTest.defined_property?(:siglum))
|
1085
|
+
assert(!DefinedAccessorTest.defined_property?(:title))
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
def test_no_defined_property
|
1089
|
+
assert(!ActiveSource.defined_property?(:siglum))
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def test_has_defined_property_on_subclass
|
1093
|
+
assert(DefinedAccessorSubTest.defined_property?(:title))
|
1094
|
+
assert(DefinedAccessorSubTest.defined_property?(:siglum))
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
def test_naked_has_defined_property_on_subclass
|
1098
|
+
assert(DefinedAccessorSubNaked.defined_property?(:siglum))
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
def test_singular_property_bracket_access
|
1102
|
+
singi = DefinedAccessorTest.new('http://www.test.org/singular_property_bracket_access')
|
1103
|
+
singi.siglum = 'foo'
|
1104
|
+
assert_equal('foo', singi[:siglum])
|
1105
|
+
singi[:siglum] = 'bar'
|
1106
|
+
assert_equal('bar', singi.siglum)
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
def test_singular_property_with_source
|
1110
|
+
related = ActiveSource.new('http://www.test.org/prop_with_sources_friend/')
|
1111
|
+
related.save!
|
1112
|
+
singi = DefinedAccessorTest.new('http://www.test.org/singular_property_with_source')
|
1113
|
+
singi.siglum = related
|
1114
|
+
singi.save!
|
1115
|
+
singi = DefinedAccessorTest.find(singi.id)
|
1116
|
+
assert_kind_of(ActiveSource, singi.siglum)
|
1117
|
+
assert_equal(related.uri, singi.siglum.uri)
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
def test_singular_property_with_uri
|
1121
|
+
related = ActiveSource.new('http://www.test.org/prop_with_uri_friend/')
|
1122
|
+
related.save!
|
1123
|
+
singi = DefinedAccessorTest.new('http://www.test.org/singular_property_with_uri')
|
1124
|
+
singi.siglum = related.to_uri
|
1125
|
+
singi.save!
|
1126
|
+
singi = DefinedAccessorTest.find(singi.id)
|
1127
|
+
assert_kind_of(ActiveSource, singi.siglum)
|
1128
|
+
assert_equal(related.uri, singi.siglum.uri)
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
def test_assign_throug_uri
|
1132
|
+
related = ActiveSource.new('http://www.test.org/assign_through_friend/')
|
1133
|
+
related.save!
|
1134
|
+
src = ActiveSource.new('http://www.test.org/assign_throug_uri')
|
1135
|
+
src[N::RDF.foo] = related.to_uri
|
1136
|
+
src.save!
|
1137
|
+
src = ActiveSource.find(src.id)
|
1138
|
+
assert_property(src[N::RDF.foo], related)
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
def test_autofill_url
|
1142
|
+
new_thing = DefinedAccessorTest.new
|
1143
|
+
assert(!new_thing.uri.blank?)
|
1144
|
+
end
|
1145
|
+
|
1146
|
+
def test_autofill_url_params
|
1147
|
+
new_thing = DefinedAccessorTest.new(:siglumm => "foo")
|
1148
|
+
assert(!new_thing.uri.blank?)
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
def test_autofill_url_params_and_save
|
1152
|
+
new_thing = DefinedAccessorTest.new(:siglumm => "foo")
|
1153
|
+
new_thing.save!
|
1154
|
+
assert(DefinedAccessorTest.exists?(new_thing.uri))
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
def test_autofill_url_not
|
1158
|
+
new_thing = DefinedAccessorSubNaked.new(:siglum => "foo")
|
1159
|
+
assert(new_thing.uri.blank?)
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
def test_manual_url_and_save
|
1163
|
+
new_thing = DefinedAccessorTest.new(:siglumm => "foo", :uri => "http://foobar.com")
|
1164
|
+
new_thing.save!
|
1165
|
+
assert(DefinedAccessorTest.exists?(new_thing.uri))
|
1166
|
+
end
|
1167
|
+
|
1168
|
+
def test_manual_property
|
1169
|
+
new_thing = DefinedAccessorTest.new(:blinko => "Bing!")
|
1170
|
+
assert_equal(new_thing.blinko, "Bing!")
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
def test_reload
|
1174
|
+
new_thing = ActiveSource.new('http://testme/testing_reload')
|
1175
|
+
new_thing.save!
|
1176
|
+
assert_property(new_thing[N::RDF.somethink])
|
1177
|
+
other_thing = ActiveSource.find(new_thing.id)
|
1178
|
+
other_thing[N::RDF.somethink] << "Bongo"
|
1179
|
+
other_thing.save!
|
1180
|
+
new_thing.reload
|
1181
|
+
assert_property(new_thing[N::RDF.somethink], "Bongo")
|
1182
|
+
end
|
1183
|
+
|
770
1184
|
private
|
771
1185
|
|
772
1186
|
def make_data_source
|
@@ -780,8 +1194,5 @@ module TaliaCore
|
|
780
1194
|
data_source.save!
|
781
1195
|
data_source
|
782
1196
|
end
|
783
|
-
|
784
|
-
|
785
1197
|
end
|
786
|
-
|
787
1198
|
end
|