def setup_method(self, method):
     self.slave_manager = dingus.Dingus("slave_manager")
     self.dl = mod.DataLoader(self.slave_manager, dingus.Dingus("http"),
                              dingus.Dingus("port"), dingus.Dingus("myIP"),
                              dingus.Dingus("db"))
     with open('test/simple.nt') as f:
         raw = f.read()
     self.dl.parseAndShardTriples(raw)
 def should_load_triples(self):
     triples = [('subject', 'predicate', 'object')]
     slave_manager = dingus.Dingus("slave_manager")
     dl = mod.DataLoader(slave_manager, dingus.Dingus("http"),
                              dingus.Dingus("port"), dingus.Dingus("myIP"),
                              dingus.Dingus("db"))
     dl.load(triples)
     assert dl.tripleCount == 4
     assert dl.db.calls('execute')
Beispiel #3
0
 def setUp(self):
     self.Image = views.Image
     views.Image = dingus.Dingus()
     self.ImageDraw = views.ImageDraw
     views.ImageDraw = dingus.Dingus()
     self.ImageFont = views.ImageFont
     views.ImageFont = dingus.Dingus()
     self.balance = views.balance
     views.balance = dingus.Dingus(return_value=(['a'], [(0, 0)]))
     self.wrap = views.wrap
     views.wrap = dingus.Dingus(return_value=(['a'], [(0, 0)]))
     self.STATICFILES_DIRS = settings.STATICFILES_DIRS
     settings.STATICFILES_DIRS = (path.join(path.dirname(__file__),
                                            'fixtures', 'test'), )
Beispiel #4
0
    def setUp(self):
        self.config = MSDSConfig(localdir=tempfile.mkdtemp())
        self.api = MSDataSyncAPI(self.config, msds_log)
        self.impl = MSDSImpl(msds_log, self.api)

        # method stub
        self.api.post_sync_step = dingus.Dingus()

        def remove_localdir():
            os.rmdir(self.config["localdir"])

        self.addCleanup(remove_localdir)

        self.rsyncconfig = self.RemoteSyncParamsStub({
            "filename1": (False, False),  # this file didn't change
            "filename2": (False, False),  # this file didn't change
            "filename3": (False, True),  # this file changed
            "asdf": (False, True),  # this file changed
        })

        self.filename_id_map = {
            "filename1": (1, 10),
            "filename2": (2, 20),
            "filename3": (3, 30),
            "filename4": (4, 40),
        }
Beispiel #5
0
 def test_requestsync_baseurl(self):
     "tests requestsync when configured sync url has no trailing slash"
     self.config["synchub"] = "http://test"
     self.config["sitename"] = "b"
     self.config["stationname"] = "c"
     self.config["organisation"] = "a"
     my_dingus = dingus.Dingus()
     with self.fake_urlopen('{ "success": true, "details": {} }') as d:
         with dingus.patch("urllib2.Request", my_dingus):
             result = self.server.requestsync()
             self.assertTrue(result["success"])
             self.assertTrue(d.calls("()").once())
         self.assertEqual(len(my_dingus.calls), 1)
         self.assertEqual(my_dingus.calls[0].args[0],
                          "http://test/requestsync/a/b/c/")
Beispiel #6
0
 def test_import_unicode(self):
     application = dingus.Dingus("application")
     request = dingus.Dingus("request")
     items = dingus.Dingus(), dingus.Dingus()
     application.ui_methods = dingus.Dingus(items__returns=[items])
     request.arguments = dingus.Dingus(get__returns=["test/ntn.n3"])
     g = pygren.GraphHandler(application, request)
     g.post('import')
     assert g.import_called
     assert not getattr(g, 'debug', None)
Beispiel #7
0
    def test_requestsync_spaces(self):
        self.config["synchub"] = "http://test"
        self.config["sitename"] = "An Interesting Site"
        self.config["stationname"] = "A Station Name"
        self.config["organisation"] = "The Organisation"

        my_dingus = dingus.Dingus()
        with self.fake_urlopen('{ "success": true, "details": {} }') as d:
            with dingus.patch("urllib2.Request", my_dingus):
                result = self.server.requestsync()
                self.assertTrue(result["success"])
                self.assertTrue(d.calls("()").once())
            self.assertEqual(len(my_dingus.calls), 1)
            self.assertEqual(
                my_dingus.calls[0].args[0],
                "http://test/requestsync/The%20Organisation/An%20Interesting%20Site/A%20Station%20Name/"
            )
Beispiel #8
0
    def test1_check_run_sample_files(self):
        """
        Check that `MSDSImpl.serverCheckRunSampleFiles()` results in
        an API call marking complete the correct samples.
        """
        Server = dingus.Dingus()
        with dingus.patch("mdatasync_client.MSDataSyncAPI.DataSyncServer",
                          Server):
            self.impl.serverCheckRunSampleFiles(self.rsyncconfig,
                                                self.filename_id_map)

        self.assertEqual(len(Server.return_value.calls), 1,
                         "One DataSyncServer instance is created")

        runsampledict, last_error = Server.return_value.calls[0][1]

        self.assertEqual(len(runsampledict), 2,
                         "Two samples are marked complete")
        self.assertEqual(runsampledict, {
            1: [10],
            2: [20]
        }, "The correct samples are marked complete")
Beispiel #9
0
    def test2_check_run_sample_files_temp_files(self):
        """
        Sample is not marked incomplete if there is a TEMP file in its
        directory.
        """
        # create a file called TEMP within a directory called
        # filename2 somewhere within the data dir
        self.create_data_file("test", "dir", "filename2", "TEMP")

        Server = dingus.Dingus()
        with dingus.patch("mdatasync_client.MSDataSyncAPI.DataSyncServer",
                          Server):
            self.impl.serverCheckRunSampleFiles(self.rsyncconfig,
                                                self.filename_id_map)

        self.assertEqual(len(Server.return_value.calls), 1,
                         "One DataSyncServer instance is created")

        runsampledict, last_error = Server.return_value.calls[0][1]

        self.assertEqual(len(runsampledict), 1,
                         "One sample is marked complete")
        self.assertEqual(runsampledict, {1: [10]},
                         "The correct sample is marked complete")
Beispiel #10
0
 def test_wrap_no_wrap(self):
     font = dingus.Dingus(getsize__returns=(30, 10))
     self.assertEqual(
         views.wrap((100, 100), font, 'abc', 'top', 'left', 10),
         (['abc'], [(10, 10)]))
Beispiel #11
0
 def fake_urlopen(json, my_dingus=None):
     my_dingus = my_dingus or dingus.Dingus()
     urlopen = dingus.Dingus(return_value=StringIO(json))
     return betterpatch("urllib2.urlopen", urlopen)
Beispiel #12
0
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# -- Options for Intersphinx  --------------------------------------------------

intersphinx_mapping = {
    'python': ('http://python.readthedocs.org/en/v2.7.2/', None),
    'django': ('http://django.readthedocs.org/en/1.4.X/', None),
    'sphinx': ('http://sphinx.readthedocs.org/en/latest/', None),
}

# -- Mock modules for autodoc building -----------------------------------------
# https://read-the-docs.readthedocs.org/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules

import dingus

MOCK_MODULES = [
    'splinter', 'wx', 'wx.lib', 'wx.lib.mixins', 'wx.lib.mixins.listctrl',
    'wx.lib.filebrowsebutton', 'wx.lib.embeddedimage'
]
for mod_name in MOCK_MODULES:
    sys.modules[mod_name] = dingus.Dingus()