OK this method is clearly better. Anyways I'll  try to redo this in bash in
near future, so most of the tests will be rewritten if I'll manage to do
it.
jb:)


2013/2/7 Diogo Baeder <notifications@github.com>

> In tests/unit/core/test_roles.py:
>
> > -            self.role.ensure_line('this line in', '/some/file', sudo=True)
> > -            execute.assert_called_with('echo "this line in" >> /some/file', stdout=False, sudo=True, user=None)
> > -
> > -    @istest
> > -    def inserts_line_with_specific_user(self):
> > -        with self.mock_role_method('has_line') as has_line, self.execute_mock() as execute:
> > -            has_line.return_value = False
> > -            self.role.ensure_line('this line in', '/some/file', owner='foo')
> > -            execute.assert_called_with('echo "this line in" >> /some/file', stdout=False, sudo=False, user='foo')
> > +    def proper_content_in_line_file(self):
> > +        with self.mock_role_method("execute_python_script") as execute, \
> > +                self.mock_role_method("put_file"), \
> > +                self.mock_role_method("create_remote_temp_file") as tmp_file:
> > +            tmp_file.return_value = "/tmp/foo"
> > +            self.role.ensure_line("foo bar", "/etc/baz")
> > +        # self.assertTrue(isinstance(put_file.mock_calls[0][1][0], StringIO))
>
> I see. But the problem is that nobody knows what something[0][1][0]means. There's even an anti-pattern name for it, called Magic
> Number<http://sourcemaking.com/refactoring/replace-magic-number-with-symbolic-constant>
> .
>
> Also, this may help you a bit:
> http://www.voidspace.org.uk/python/mock/examples.html#more-complex-argument-matching
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/python-provy/provy/pull/113/files#r2926236>.
>
>