Esempio n. 1
0
    def test_get_context_variable(self):
        state = State()

        state.update_context_variables({'PROJECT_NAME': 'foo'})

        self.assertEqual(state.get_context_variable('PROJECT_NAME'), 'foo')
        self.assertNotEqual(state.get_context_variable('not_created'), 'foo')
Esempio n. 2
0
    def test_update_context_variables(self):
        state = State()

        state.update_context_variables([1, 2, 3])

        self.mocked_facio_state_State_warning.assert_called_once_with(
            'Failed to update context variables with [1, 2, 3]')
Esempio n. 3
0
    def test_get_context_variables(self):
        state = State()

        state.update_context_variables({'PROJECT_NAME': 'foo'})

        self.assertEqual(state.get_context_variables(),
                         {'PROJECT_NAME': 'foo'})
Esempio n. 4
0
    def test_get_hook_call(self):
        state = State()

        state.save_hook_call('foo.bar', 'baz')
        state.save_hook_call('baz.foo', 'bar')

        self.assertEqual(state.get_hook_call('foo.bar'), 'baz')
        self.assertEqual(state.get_hook_call('baz.foo'), 'bar')
Esempio n. 5
0
    def test_save_hook_call(self):
        state = State()

        state.save_hook_call('foo.bar', 'baz')
        state.save_hook_call('baz.foo', 'bar')
        calls = state.save_hook_call('foo.bar', 'baz')

        self.assertEqual(calls, [('foo.bar', 'baz'), ('baz.foo', 'bar')])
Esempio n. 6
0
    def test_get_context_variables_empty(self):
        state = State()

        self.assertEqual(state.get_context_variables(), {})
Esempio n. 7
0
    def test_return_project_root(self, mock_pwd):
        state = State()
        state.set_project_name('foo')

        self.assertEqual(state.get_project_root(), '/bar/foo')
Esempio n. 8
0
    def test_return_current_working_dir(self, mock_pwd):
        state = State()
        state.set_project_name('foo')

        self.assertEqual(state.get_working_directory(), '/foo')
Esempio n. 9
0
    def test_get_set_project_name(self):
        state = State()
        state.set_project_name('foo')

        self.assertEqual(state.get_project_name(), 'foo')
Esempio n. 10
0
    def test_same_instance_always_returned(self):
        s1 = State()
        s2 = State()

        self.assertEqual(s1.state, s2.state)