Beispiel #1
0
    def test_plot_option_fileopt_deprecations(self):

        # Make sure DeprecationWarnings aren't filtered out by nose
        warnings.filterwarnings('default', category=DeprecationWarning)

        # If filename is not given and fileopt is not 'new',
        # raise a deprecation warning
        kwargs = {
            'auto_open': True,
            'fileopt': 'overwrite',
            'validate': True,
            'sharing': 'private'
        }

        with warnings.catch_warnings(record=True) as w:
            plot_option_logic = py._plot_option_logic(kwargs)
            assert w[0].category == DeprecationWarning

        expected_plot_option_logic = {
            'filename': 'plot from API',
            'auto_open': True,
            'fileopt': 'overwrite',
            'validate': True,
            'world_readable': False,
            'sharing': 'private'
        }
        self.assertEqual(plot_option_logic, expected_plot_option_logic)

        # If filename is given and fileopt is not 'overwrite',
        # raise a depreacation warning
        kwargs = {
            'filename': 'test',
            'auto_open': True,
            'fileopt': 'append',
            'validate': True,
            'sharing': 'private'
        }

        with warnings.catch_warnings(record=True) as w:
            plot_option_logic = py._plot_option_logic(kwargs)
            assert w[0].category == DeprecationWarning

        expected_plot_option_logic = {
            'filename': 'test',
            'auto_open': True,
            'fileopt': 'append',
            'validate': True,
            'world_readable': False,
            'sharing': 'private'
        }
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #2
0
    def test_plot_option_fileopt_deprecations(self):

        # Make sure DeprecationWarnings aren't filtered out by nose
        warnings.filterwarnings('default', category=DeprecationWarning)

        # If filename is not given and fileopt is not 'new',
        # raise a deprecation warning
        kwargs = {'auto_open': True,
                  'fileopt': 'overwrite',
                  'validate': True,
                  'sharing': 'private'}

        with warnings.catch_warnings(record=True) as w:
            plot_option_logic = py._plot_option_logic(kwargs)
            assert w[0].category == DeprecationWarning

        expected_plot_option_logic = {'filename': 'plot from API',
                                      'auto_open': True,
                                      'fileopt': 'overwrite',
                                      'validate': True,
                                      'world_readable': False,
                                      'sharing': 'private'}
        self.assertEqual(plot_option_logic, expected_plot_option_logic)

        # If filename is given and fileopt is not 'overwrite',
        # raise a depreacation warning
        kwargs = {'filename': 'test',
                  'auto_open': True,
                  'fileopt': 'append',
                  'validate': True,
                  'sharing': 'private'}

        with warnings.catch_warnings(record=True) as w:
            plot_option_logic = py._plot_option_logic(kwargs)
            assert w[0].category == DeprecationWarning

        expected_plot_option_logic = {'filename': 'test',
                                      'auto_open': True,
                                      'fileopt': 'append',
                                      'validate': True,
                                      'world_readable': False,
                                      'sharing': 'private'}
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #3
0
 def test_set_config_updates_plot_options(self):
     original_config = tls.get_config_file()
     new_options = {
         'world_readable': not original_config['world_readable'],
         'auto_open': not original_config['auto_open'],
         'sharing': ('public' if original_config['world_readable'] is False
                     else 'secret')
     }
     tls.set_config_file(**new_options)
     options = py._plot_option_logic({})
     for key in new_options:
         self.assertEqual(new_options[key], options[key])
Beispiel #4
0
    def test_plot_option_logic_only_sharing_given(self):

        # If world_readable is not given and sharing ='private',
        # world_readable should be set to False

        kwargs = {'filename': 'test',
                  'auto_open': True,
                  'fileopt': 'overwrite',
                  'validate': True,
                  'sharing': 'private'}

        plot_option_logic = py._plot_option_logic(kwargs)

        expected_plot_option_logic = {'filename': 'test',
                                      'auto_open': True,
                                      'fileopt': 'overwrite',
                                      'validate': True,
                                      'world_readable': False,
                                      'sharing': 'private'}
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #5
0
    def test_plot_option_logic_only_world_readable_given(self):

        # If sharing is not given and world_readable=False,
        # sharing should be set to None

        kwargs = {'filename': 'test',
                  'auto_open': True,
                  'fileopt': 'overwrite',
                  'validate': True,
                  'world_readable': False}

        plot_option_logic = py._plot_option_logic(kwargs)

        expected_plot_option_logic = {'filename': 'test',
                                      'auto_open': True,
                                      'fileopt': 'overwrite',
                                      'validate': True,
                                      'world_readable': False,
                                      'sharing': None}
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #6
0
    def test_plot_option_logic_only_sharing_given(self):

        # If world_readable is not given and sharing ='private',
        # world_readable should be set to False

        kwargs = {'filename': 'test',
                  'auto_open': True,
                  'fileopt': 'overwrite',
                  'validate': True,
                  'sharing': 'private'}

        plot_option_logic = py._plot_option_logic(kwargs)

        expected_plot_option_logic = {'filename': 'test',
                                      'auto_open': True,
                                      'fileopt': 'overwrite',
                                      'validate': True,
                                      'world_readable': False,
                                      'sharing': 'private'}
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #7
0
    def test_plot_option_logic_only_world_readable_given(self):

        # If sharing is not given and world_readable=False,
        # sharing should be set to None

        kwargs = {
            'filename': 'test',
            'auto_open': True,
            'fileopt': 'overwrite',
            'validate': True,
            'world_readable': False
        }

        plot_option_logic = py._plot_option_logic(kwargs)

        expected_plot_option_logic = {
            'filename': 'test',
            'auto_open': True,
            'fileopt': 'overwrite',
            'validate': True,
            'world_readable': False,
            'sharing': None
        }
        self.assertEqual(plot_option_logic, expected_plot_option_logic)
Beispiel #8
0
 def test(self):
     tls.set_config(**plot_options['parent'])
     options = py._plot_option_logic(plot_options['child'])
     for option, value in plot_options['expected_output'].items():
         self.assertEqual(options[option], value)
Beispiel #9
0
 def test(self):
     py.sign_in('username', 'key', **plot_options['parent'])
     options = py._plot_option_logic(plot_options['child'])
     for option, value in plot_options['expected_output'].items():
         self.assertEqual(options[option], value)
Beispiel #10
0
 def test_default_options(self):
     options = py._plot_option_logic({})
     config_options = tls.get_config_file()
     for key in options:
         if key != 'fileopt' and key in config_options:
             self.assertEqual(options[key], config_options[key])