Exemplo n.º 1
0
Arquivo: admin.py Projeto: siadyhr/web
 def get_titles(self, profile):
     titles = list(profile.title_set.all())
     if titles:
         with tk.set_gfyear(config.GFYEAR):
             return ', '.join(
                 sorted(
                     tk.prepostfix(t, prefixtype="unicode")
                     for t in titles))
Exemplo n.º 2
0
 def __init__(self, **kwargs):
     profiles = kwargs.pop('profiles')
     try:
         period = kwargs.pop('period')
     except KeyError:
         period = config.GFYEAR
     super().__init__(**kwargs)
     with tk.set_gfyear(period):
         self._init(profiles)
Exemplo n.º 3
0
    def test_called_once(self):
        calls = 0

        def get_value():
            nonlocal calls
            calls += 1
            return 2013

        o = tk.set_gfyear(get_value)
        self.assertEqual(calls, 0)
        with o:
            self.assertEqual(calls, 1)
            self.assertEqual(tk.get_gfyear(), 2013)
            self.assertEqual(calls, 1)
            self.assertEqual(tk.get_gfyear(), 2013)
            self.assertEqual(calls, 1)
Exemplo n.º 4
0
 def test_postfix_leadingspace_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' FORM 1617'), ('FORM', 2016))
Exemplo n.º 5
0
 def test_kprefix(self):
     with tk.set_gfyear(2015):
         self.assertEqual(tk.kprefix(('CERM', 2014)), 'KBCERM')
Exemplo n.º 6
0
 def test_AAE(self):
     with tk.set_gfyear(2013):
         with self.assertRaisesRegex(
                 ValueError, "FUAAE is an ambiguous alias. Cannot "
                 "normalize."):
             tk.parse('FUAAE11')
Exemplo n.º 7
0
 def test_FUAEU_absolute_later(self):
     with tk.set_gfyear(2023):
         self.assertEqual(tk.parse('FUAEU21'), ('FUÄU', 2021))
Exemplo n.º 8
0
 def test_AE_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAE11'), ('FUAE', 2011))
Exemplo n.º 9
0
 def test_OE_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUOEH11'), ('FUØH', 2011))
Exemplo n.º 10
0
 def test_prefix_unicode_plus_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('K³FORM'), ('FORM', 2016))
Exemplo n.º 11
0
 def test_prefix_unicode_combined_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OK³FORM'), ('FORM', 2011))
Exemplo n.º 12
0
 def test_prefix_unicode_minus_35(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T³²OFORM'), ('FORM', 1978))
Exemplo n.º 13
0
 def test_prefix_plus_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('KFORM'), ('FORM', 2014))
Exemplo n.º 14
0
 def test_prefix_minus_5(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OFORM'), ('FORM', 2008))
Exemplo n.º 15
0
 def test_context(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM'), ('FORM', 2013))
Exemplo n.º 16
0
 def test_postfix(self):
     with tk.set_gfyear(2015):
         self.assertEqual(tk.postfix(('CERM', 2014)), 'CERM14')
Exemplo n.º 17
0
 def test_postfix_bestfu(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BESTFU16'), ('BESTFU', 2016))
Exemplo n.º 18
0
 def test_postfix_double(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM1617'), ('FORM', 2016))
Exemplo n.º 19
0
 def test_prefix_bestfuslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BBEST/FU'), ('BESTFU', 2011))
Exemplo n.º 20
0
 def test_postfix_long(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016'), ('FORM', 2016))
Exemplo n.º 21
0
 def test_OE_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUHOE11'), ('FUHØ', 2011))
Exemplo n.º 22
0
 def test_postfix_reallylongslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016/2017'), ('FORM', 2016))
Exemplo n.º 23
0
 def test_AAAA(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAAAA11'), ('FUÅÅ', 2011))
Exemplo n.º 24
0
 def test_postfix_2021_slash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM20/21'), ('FORM', 2020))
Exemplo n.º 25
0
 def test_FUAEU_relative_next_year(self):
     with tk.set_gfyear(2022):
         self.assertEqual(tk.parse('GFUAEU'), ('FUÄU', 2021))
Exemplo n.º 26
0
 def test_context_manager(self):
     with tk.set_gfyear(2012):
         self.assertEqual(tk.get_gfyear(), 2012)
Exemplo n.º 27
0
 def test_lambda(self):
     with tk.set_gfyear(lambda: 2013):
         self.assertEqual(tk.get_gfyear(), 2013)
Exemplo n.º 28
0
 def test_prefix_leadingspace(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' T2OFORM'), ('FORM', 2008))
Exemplo n.º 29
0
 def test_postfix_longslash_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM 2016/17'), ('FORM', 2016))
Exemplo n.º 30
0
 def test_reentrant(self):
     with tk.set_gfyear(2011):
         self.assertEqual(tk.get_gfyear(), 2011)
         with tk.set_gfyear(2012):
             self.assertEqual(tk.get_gfyear(), 2012)
         self.assertEqual(tk.get_gfyear(), 2011)