Giter Club home page Giter Club logo

charlatan's People

Contributors

andrewnester avatar charlax avatar chunyan avatar danqing avatar dnathe4th avatar genepeng avatar jimmycuadra avatar jordanb avatar joshualross avatar jvrsantacruz avatar kmnovak avatar mrbrowning avatar msabramo avatar roguelazer avatar ronaldouyang avatar rtoussaint avatar sweenzor avatar yandongliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

charlatan's Issues

Nested custom constructors are not evaluated

This could be a problem with pyyaml itself.

When creating fixtures without models and nesting !now only first level is evaluated

This yaml definition:

simple_dict:
  fields:
    created_at: !now
    nested:
      created_at: !now

produces this output:

{ 
    'created_at': datetime.datetime(2015, 11, 25, 17, 27, 3, 119923, tzinfo=<UTC>), 
    'nested': {
        'created_at': <function configure_yaml.<locals>.now_constructor.<locals>.get_now at 0x1052cbbf8>
    }
}

Cheers,
Jakub

FixturesManager should extend a list of filenames rather than append

The doc for FixturesManager states that it accepts "list_or_str" of filenames. However, it always calls extend on the given parameter. If the input is a list, appending a list to a list gives you a list of lists. In this case self.filenames should be extending the given input.

Sqlalchemy does not commit items installed through post_creation

When I reference a fixture in a post_creation section using !rel, it is created and added to relationship but I have to manually run an extra commit afterwards.

Results in code like:

fix.install_fixture(name)
db.session.commit()

Feels like I shouldn't need to do this...?

Can we have factory features in install_fixtures not just install_fixture

Currently if we want to override a field for a fixture,
we have to use install_fixture like so

self.install_fixture('foo', overrides={'a': 'baz'})
self.install_fixtures((
'foo',
'bar',
'baz'
))

however, the ability to do this inline would be nice:

self.install_fixtures((
'foo',
'bar',
'baz',
('foo', overrides={'a': 'baz'})
))

Error while getting fixture with anonymous references

Error resolving anonymous references based on list of objects:

(...)
charlatan/utils.pyc in richgetter(obj, path)
    174             obj = getattr(obj, name)
    175             continue
--> 176         obj = obj[name]
    177 
    178     return obj

TypeError: list indices must be integers, not str

This happens loading the fixture

>>> import charlatan
>>> fm = charlatan.FixturesManager(session)
>>> fm.load('fixtures.yaml', 'app.models')

# Specific index is OK
>>> fm.get_fixture('department.0')
Department

# Whole collection raises error
>>> fm.get_fixture('departments')
(...)
TypeError: list indices must be integers, not str
office:
  model: Office

offices:
  inherit_from: office
  objects:
    -
       name: 'Office0'

    -
       name: 'Office1'

department:
  model: Department

departments:
  inherit_from: department
  objects:
    -
       name: 'Department0'
       office: !rel offices.0

    -
       name: 'Department1'
       office: !rel offices.1

It works using keys 0, 1 for offices instead of a list, but it changes the get_fixture return type from list to dict.

InstallAndSave builder should allow deferring transaction commit

The default SQLAlchemy builder (InstallAndSave) commits the session on each individual fixture.

In some cases, it may be more desirable to allow all fixtures to be instantiated added to the session before committing the entire session. For example, if any semantic error occurs (valid YAML, but invalid for the SQLAlchemy model), the application may wish to roll back all fixture changes rather than commit partial data.

This could be done by adding a autocommit boolean kwarg to the __call__ method that would skip this session commit call.

Allow depend_on for collections

Currently depend_on appears to be ignored on collections.

I can't see how to use depend_on for either the parent collection or the child objects. Ideally I'd like the whole collection to depend on another collection.

Possible to generate fixtures from database?

Charlatan seems like a very nice way to manage and load fixture data. Is it possible to go the other way, and generate fixtures from an existing database?

Django's fixture management lets you do this via manage.py dumpdata. It's a useful way to capture database state to something that's human readable/editable and less brittle than sqldump.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.