Example #1
0
def test_querypath_parsing():
    mrun = MockRuntimeForQuerying()
    block = Mock()
    mrun.querypath(block, "..//@hello")
    print mrun.mock_query.mock_calls
    expected = Mock()
    expected.parent().descendants().attr("hello")
    assert mrun.mock_query.mock_calls == expected.mock_calls
Example #2
0
    def test_pushing_after_popping_creates_a_new_root_step(self):
        registry = Registry().reset()
        step1 = Mock()
        step1.parent = None
        step2 = Mock()
        step2.parent = None

        registry.push(step1)
        registry.pop()
        registry.push(step2)

        self.assertEquals([step1, step2], registry.root_steps)
Example #3
0
 def test_get_context_key(self):
     view = self._test_view()
     parent = Mock(id_name="foobar")
     resource = Mock()
     resource.parent = parent
     view._resource = resource
     assert view._get_context_key(foobar=1, foo=2) == "1"
 def setupStatus(self, b):
     botmaster = Mock()
     botmaster.parent = Mock()
     botmaster.parent.buildbotURL = "http://buildbot:8010/"
     s = builder.Status(botmaster=botmaster, basedir=b.basedir)
     b.status = s
     return s
Example #5
0
    def test_pop_does_not_fail_if_step_has_no_parent(self):
        registry = Registry().reset()
        step = Mock()
        step.parent = None
        registry.push(step)

        self.assertEquals(None, registry.pop())
Example #6
0
 def test_get_static_parent_without_method_parent_present(self):
     root = Mock(resources=[Mock(path="/stories", method="options"), Mock(path="/stories", method="post")])
     parent = Mock(path="/stories", method="get", root=root)
     resource = Mock(path="/{id}")
     resource.parent = parent
     res = utils.get_static_parent(resource)
     assert res.method == "get"
     assert res.path == "/stories"
Example #7
0
 def add(self):
     u = Mock(spec=Uzbl)
     u.parent = self
     u.logger = logging.getLogger("debug")
     u.plugins = {}
     for plugin in self.instance_plugins:
         u.plugins[plugin] = plugin(u)
     for (plugin, mock) in self.instance_mock_plugins:
         u.plugins[plugin] = mock() if mock else Mock(plugin)
     self.uzbls[Mock()] = u
     return u
Example #8
0
 def test_get_static_parent_none_found_in_root(self):
     root = Mock(resources=[Mock(path="/stories", method="get")])
     parent = Mock(path="/stories", method="options", root=root)
     resource = Mock(path="/{id}")
     resource.parent = parent
     assert utils.get_static_parent(resource, method="post") is None
Example #9
0
 def test_get_static_parent_none(self):
     resource = Mock(path="/{id}")
     resource.parent = None
     assert utils.get_static_parent(resource, method="post") is None
Example #10
0
 def test_get_static_parent(self):
     parent = Mock(path="/stories", method="post")
     resource = Mock(path="/{id}")
     resource.parent = parent
     assert utils.get_static_parent(resource, method="post") is parent
Example #11
0
 def test_remote_id(self):
     step = Mock()
     step.parent = Mock(repo_id="123")
     remote = Remote(step, None)
     self.assertEqual(remote.remote_id, step.parent.repo_id)
Example #12
0
 def test_url(self):
     step = Mock()
     step.parent = Mock(feed_url="http://")
     remote = Remote(step, None)
     self.assertEqual(remote.url, step.parent.feed_url)